/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _HUGETLB_FIXCOUNTS_H
#define _HUGETLB_FIXCOUNTS_H
#ifdef CONFIG_EULEROS_FIX_TOTAL_HUGETLB_COUNTS
#include <linux/mm_types.h>
#include <linux/mm.h>
#include <linux/hugetlb.h>
#include <linux/dynamic_hugetlb.h>
#include <linux/page-flags.h>
#include <linux/spinlock.h>
static inline void hugetlb_fix_total_counts(struct page *page)
{
	struct hstate *h = page_hstate(page);
	int nid = page_to_nid(page);

	if (dhugetlb_enabled && PagePool(page))
		return;
	spin_lock(&hugetlb_lock);
	h->max_huge_pages--;
	h->nr_huge_pages--;
	h->nr_huge_pages_node[nid]--;
	spin_unlock(&hugetlb_lock);
}
#else
static inline void hugetlb_fix_total_counts(struct page *page) {}

#endif

#endif
